package com.sujiewon.salesadmin.common.dao;

import java.sql.SQLException;
import java.util.HashMap;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;

@Repository
public class VisitDaoImpl implements VisitDao {

	@Resource(name="sqlMapClient")
	private SqlMapClient sqlMapClient;
	
	@SuppressWarnings("unchecked")
	@Override
	public boolean isExistTodayCnt(String date) throws SQLException {
		boolean returnValue = true;
		HashMap<String, Object> result = (HashMap<String, Object>)this.sqlMapClient.queryForObject("visit.isExistTodayCnt", date);
		if(result == null || result.isEmpty()){
			returnValue = false;
		}
		return returnValue;
	}

	@Override
	public void insertTodayCnt(String date) throws SQLException {
		this.sqlMapClient.insert("visit.insertTodayCnt", date);
	}

	@Override
	public void updateTodayCnt(String date) throws SQLException {
		this.sqlMapClient.update("visit.updateTodayCnt", date);
	}

	@Override
	public int getTodayCnt(String date) throws SQLException {
		return (Integer)this.sqlMapClient.queryForObject("visit.getTodayCnt", date);
	}

	@Override
	public int getTotalCnt() throws SQLException {
		return (Integer)this.sqlMapClient.queryForObject("visit.getTotalCnt");
	}

}
